package com.FengChaoSystem.service.OccupyService;

import com.FengChaoSystem.dao.OccupyDao;
import com.FengChaoSystem.pojo.Occupy;
import com.FengChaoSystem.service.OccupyImpl;
import com.FengChaoSystem.untils.SqlSessionFactoryUtils;
import com.Mybatis.session.SqlSession;
import com.Mybatis.session.SqlSessionFactory;

public class OccupyService implements OccupyImpl {
    SqlSessionFactory sqlSessionFactory= SqlSessionFactoryUtils.getSqlSessionFactory();
    @Override
    public Occupy selectGetWordAndReceiveAddress(Occupy target) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        OccupyDao mapper = sqlSession.getMapper(OccupyDao.class);
        Occupy occupy = mapper.selectGetWordAndReceiveAddress(target);
        sqlSession.close();
        return occupy;
    }

    @Override
    public void updateOccupyStatus(Occupy occupy) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        OccupyDao mapper = sqlSession.getMapper(OccupyDao.class);
        mapper.updateOccupyStatus(occupy);
        sqlSession.commit();
        sqlSession.close();
    }


}
